#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int inf=0x7ffffff;

long long min(long long a, long long b) {
  return a<b ? a : b;
}

void sort(int a[][3], int l, int r) {
  int i=l, j=r, mid=a[(l+r)/2][0], temp;
  for (; i<=j; ) {
    for (; a[j][0]>mid; j--);
    for (; a[i][0]<mid; i++);
    if (i<=j) {
      for (int k=0; k<3; k++) {
	temp=a[i][k], a[i][k]=a[j][k], a[j][k]=temp;
      }
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, i, r);
  }
  if (j>l) {
    sort(a, l, j);
  }
}

void initSet(int *set, int n) {
  for (int i=1; i<=n; i++) {
    set[i]=i;
  }
}

int getFa(int *set, int o) {
  return set[o]==o ? o : (set[o]=getFa(set, set[o]));
}

int main() {
#ifdef DEBUG
  freopen("0.in", "r", stdin);
  freopen("0.out", "w", stdout);
#endif

  const int maxn=1000;
  const int maxm=5000;

  static int side[maxm+2][3];
  static long long v[maxn+1];

  int n, m;
  long long k;
  scanf("%d %d %lld", &n, &m, &k);
  for (int i=1; i<=n; i++) {
    scanf("%lld", v+i);
  }
  for (int i=1; i<=m; i++) {
    scanf("%d %d %d", side[i]+1, side[i]+2, side[i]);
  }
  sort(side, 1, m);

  static int set[maxn+1], size[maxn+1];
  int a, b, ans=inf;
  long long sum;
  for (int i=1; i<=m; i++) {
    if (side[i+1][0]!=side[i][0]) {
      sum=n*v[1];
      initSet(set, n);
      for (int j=1; j<=n; j++) {
	size[j]=1;
      }

      for (int j=i; j>0; j--) {
	if ((a=getFa(set, side[j][1]))!=(b=getFa(set, side[j][2]))) {
	  sum += v[size[a]+size[b]]-v[size[b]]-v[size[a]];
	  size[a]+=size[b];
	  size[b]=0;
	  set[b]=a;
	}
	if (side[j][0]!=side[j-1][0]) {
	  if (sum>=k) {
	    ans = min(ans, side[i][0]-side[j][0]);
	    break;
	  }
	}
      }
    }
  }

  printf(ans==inf ? "T_T" : "%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
